//
//  WSGSegmented.m
//  oneDollar
//
//  Created by Laki on 16/6/17.
//  Copyright © 2016年 com.Laki.corder. All rights reserved.
//

#import "WSGSegmented.h"

@implementation WSGSegmented

- (instancetype)initWithItems:(NSArray *)items{
    if (self = [super initWithItems:items]) {
        // 设置Segmented的Frame
        self.frame = CGRectMake(0, 0, ScreenW, 35);
        
        // 设置Segmented的主题颜色
        [self setTintColor:[UIColor whiteColor]];
        
        // 设置Segmented被选中状态下的属性
        NSMutableDictionary *selectAttributes = [NSMutableDictionary dictionary];
        // 设置字体大小
        selectAttributes[NSFontAttributeName] = [UIFont systemFontOfSize:16];
        // 设置字体颜色
        selectAttributes[NSForegroundColorAttributeName] = [UIColor colorWithRed:217.0 / 255.0 green:29.0 / 255.0 blue:55.0 / 255.0 alpha:1.0];
        // 设置属性
        [self setTitleTextAttributes:selectAttributes forState:UIControlStateSelected];
        
        // 设置Segmented默认状态下的属性
        NSMutableDictionary *normalAttributes = [NSMutableDictionary dictionary];
        // 设置字体大小
        normalAttributes[NSFontAttributeName] = [UIFont systemFontOfSize:14];
        // 设置字体颜色
        normalAttributes[NSForegroundColorAttributeName] = [UIColor colorWithRed:60.0 / 255.0 green:62.0 / 255.0 blue:69.0 / 255.0 alpha:1.0];
        // 设置属性
        [self setTitleTextAttributes:normalAttributes forState:UIControlStateNormal];
        
        // 默认选中索引为第0个的按钮
        self.selectedSegmentIndex = 0;
        
    }
    return self;
}

@end
